<?php require_once('../Connections/miportal.php'); 
mysql_query("SET NAMES 'utf8'");
?>
<?php

if (!isset($_SESSION)) {
  @session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && true) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}

$MM_restrictGoTo = "../private/login.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}



$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form_add_rov")) {
	$id_convocatoria=NULL;

	if($_POST['selectPrograma']=="BECAS VINCULACION"){$id_convocatoria=17;}else
	if($_POST['selectPrograma']=="EXPERIMENTA"){$id_convocatoria=18;}else
	if($_POST['selectPrograma']=="EMPLEATE"){$id_convocatoria=19;}else
	if($_POST['selectPrograma']=="MI PRIMERA EMPRESA"){$id_convocatoria=20;}else
	if($_POST['selectPrograma']=="I+D+i"){$id_convocatoria=21;}
	
   
			
  $insertSQL = sprintf("INSERT INTO cat2_usuario (tp_programa, nmb_titulo, nmb_nombres, nmb_apaterno, nmb_amaterno, 
  inf_correo_p, inf_area, inf_cargo, inf_telefono_oficina, inf_extension, inf_telefono_opcional, acs_password, acs_usuario, id_target, tp_perfil, id_cat_convocatoria) VALUES
   (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
					   GetSQLValueString($_POST['selectPrograma'], "text"),
                       GetSQLValueString($_POST['ins_titulo'], "text"),
                       GetSQLValueString($_POST['insNombre'], "text"),
                       GetSQLValueString($_POST['insPaterno'], "text"),
                       GetSQLValueString($_POST['insMaterno'], "text"),
                       GetSQLValueString($_POST['insCorreo'], "text"),
                       GetSQLValueString($_POST['insArea'], "text"),
                       GetSQLValueString($_POST['insCargo'], "text"),
                       GetSQLValueString($_POST['insTelefono'], "text"),
                       GetSQLValueString($_POST['insExtension'], "text"),
                       GetSQLValueString($_POST['insCelular'], "text"),
					   GetSQLValueString($_POST['insContrasena'], "text"),
                       GetSQLValueString($_POST['insUsuario'], "text"),
					   GetSQLValueString($_SESSION['MM_id_target'], "int"),
					   GetSQLValueString("ROV", "text"),
					   GetSQLValueString($id_convocatoria, "int")
					   
					   );

  mysql_select_db($database_miportal, $miportal);
  $Result1 = mysql_query($insertSQL, $miportal) or die(mysql_error());
  //SELECT A LA BASE DE DATOS PARA OBTENER USUARIO Y CONTRASEÑA
	  mysql_select_db($database_miportal, $miportal);
	$query_rs_rov = sprintf("SELECT id_usuario, acs_usuario, acs_password FROM cat2_usuario WHERE acs_usuario = %s AND acs_password=%s", 
							GetSQLValueString($_POST['insUsuario'], "text"),
							GetSQLValueString($_POST['insContrasena'], "text"));
	$rs_rov = mysql_query($query_rs_rov, $miportal) or die(mysql_error());
	$row_rs_rov = mysql_fetch_assoc($rs_rov);
	$totalRows_rs_rov = mysql_num_rows($rs_rov);
  
  /**INSERT EN BASE DE DATOS**/
	
	 $insert_accs_usr_SQL = sprintf("INSERT INTO acs_control_usuario (id_usuario, aut_nom_usuario, aut_passwd) VALUES (%s,%s,%s)",
                       GetSQLValueString($row_rs_rov['id_usuario'], "int"),
					   GetSQLValueString($row_rs_rov['acs_usuario'], "text"),
					   GetSQLValueString($row_rs_rov['acs_password'], "text"));
 mysql_select_db($database_miportal, $miportal);
  $Result1 = mysql_query($insert_accs_usr_SQL, $miportal) or die(mysql_error());
  /***///updates
 $UPDATE_SQL = "UPDATE cat2_usuario SET nmb_target=(SELECT cat_ies.id_nmbNombre FROM cat_ies WHERE cat2_usuario.id_target=cat_ies.id_cat_ies)";
 mysql_select_db($database_miportal, $miportal);
  $Result1 = mysql_query($UPDATE_SQL, $miportal) or die(mysql_error());
  /* $UPDATE_SQL = "UPDATE cat_ies set nb_domicilio=(SELECT inf_direccion_ies FROM cat2_usuario WHERE cat2_usuario.id_target=cat_ies.id_cat_ies and inf_direccion_ies<>'' LIMIT 1)";
 mysql_select_db($database_miportal, $miportal);
  $Result1 = mysql_query($UPDATE_SQL, $miportal) or die(mysql_error());
  */
  echo"<script language=\"javascript\">window.location=\"../report/report_riv_rov.php\"</script>;";
  
}
	
?>







<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximun-scale=1">
<title>FUNDACIÓN EDUCACIÓN SUPERIOR-EMPRESA</title>
<!--Hoja de estilo principal-->
<link href="../css/styletd2.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="shortcut icon" href="stylesheet/img/devil-icon.png"> 
<link rel="stylesheet" type="text/css" href="../css/mos-style.css">
<link rel="stylesheet" type="text/css" href="../css/menu.css"><!--Pemanggilan gambar favicon-->
 <!--pemanggilan file css-->
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
<link href="../SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css">
<link href="../SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css">
<script language=""="JavaScript">
	function conMayusculas(field) {
				field.value = field.value.toUpperCase()
		}
			function incubadora(val) {
				documen.write(val);
		}
	function MM_jumpMenu(targ,selObj,restore){ //v3.0
	  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	  if (restore) selObj.selectedIndex=0;
	}

	function confirmar ( mensaje ) {
					return confirm( mensaje );
				}
        </script>
</head>
<body>
 <header>
    <div id="background"></div><!--BackGround Menu header-->
		<div class="img_header_logo"></div>
		<span class="img_header_logo"><a href="http://fese.org.mx"><img src="../images/fese/FESE_home_logo.png"  height="90" alt="FESE" align="bottom" /></a></span>
		<div class="img_header_logo"></div>
		<div id="nav">
		<ul>
		  <li class="nivel1"><a href="../private/riv.php" class="nivel1">Inicio</a></li>
		 <!-- <li class="nivel1"><a href="../report/report_riv_emp.php" class="nivel1">Empléate</a></li>
		  <li class="nivel1"><a href="../report/report_riv_exp.php" class="nivel1">Experimenta</a></li>
		  <li class="nivel1"><a href="../report/report_riv_mpe.php" class="nivel1">MPE</a></li>  -->
		 <!-- <li class="nivel1"><a href="../report_riv_bv.php" class="nivel1">BV</a></li>  -->
		  <li class="nivel1"><a href="../report/report_riv_rov.php" class="nivel1">Cuentas</a></li>
		</ul>
		</div><!--Menu NAV-->
</header>

<center>
<div id="boxcontainer">
<form action="<?php echo $editFormAction; ?>" method="POST" name="form_add_rov">
<table name="t_candidato" min-width="620px" border="1" style="margin:0 auto; padding-left:5%;">
	<tr>
	  <td colspan="2">&nbsp;</td>
	  </tr>
	<tr>
		<td colspan="2"><h3 style="text-align:left; margin-left:-20px;">DATOS DEL RESPONSABLE OPERATIVO DE VINCULACION (ROV)</h3>
		  <p style="text-align:left; margin-left:-20px; font-weight: bold;">Recuerde que sólamente podrá tener un ROV por programa.</p></td>
		</tr>
	<tr>
    
    <tr> <td>Programa*</td> <td><span id="selectPrograma">
    <select name="selectPrograma" id="selectPrograma">
      <option value="EMPLEATE" selected>EMPLÉATE</option>
      <option value="EXPERIMENTA">EXPERIMENTA</option>
      <option value="MI PRIMERA EMPRESA">MI PRIMERA EMPRESA</option>
      <option value="BECAS VINCULACION">BECAS VINCULACIÓN</option>
    
    </select>
    <span class="selectRequiredMsg">Seleccione un elemento.</span></span></td>
    </tr>
    
    <td>Título*</td>
		<td><span id="SelecTitulo">
		  <select name="ins_titulo" id="ins_titulo">
		    <option value="C.">C.</option>
		    <option value="TSU.">TSU.</option>
		    <option value="LIC." selected>LIC.</option>
		    <option value="ING.">ING.</option>
		    <option value="MTRO.">MTRO.</option>
		    <option value="MTRA.">MTRA.</option>
		    <option value="DR.">DR.</option>
		    <option value="DRA.">DRA.</option>
		    </select>
		  <span class="selectRequiredMsg">Seleccione un elemento.</span></span></td>   
     <tr>
		<td>Nombre(s)*</td>
		<td ><span id="nombre">
		  <input type="text" name="insNombre" id="insNombre" onChange="conMayusculas(this)" style="width:280px">
		  <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
	</tr>
	<tr>
		<td>Apellido Paterno*</td>
		<td ><span id="aPaterno">
		  <input type="text" name="insPaterno" id="insPaterno" onChange="conMayusculas(this)" style="width:280px">
		  <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
	</tr>
	<tr>
		<td>Apellido Materno*</td>
		<td><span id="aMaterno">
		  <input type="text" name="insMaterno" id="insMaterno" onChange="conMayusculas(this)" style="width:280px">
		  <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
	</tr>
	<tr>
		<td>Correo electrónico*</td>
		<td><span id="correo">
        <input type="text" name="insCorreo" id="insCorreo" onChange="conMayusculas(this)" style="width:280px">
        <span class="textfieldRequiredMsg">Se necesita un valor.</span><span class="textfieldInvalidFormatMsg">Formato no válido.</span></span></td>
	</tr>
	<tr>
		<td>Validar correo*</td>
		<td><span id="validacionCorreo">
		  <input type="text" name="insValidarCorreo" id="insValidarCorreo" onChange="conMayusculas(this)" style="width:280px">
		  <span class="confirmRequiredMsg">Se necesita un valor.</span><span class="confirmInvalidMsg">Los valores no coinciden.</span></span></td>
	</tr>
    <tr>
		<td>Teléfono oficina con LADA*</td>
		<td><span id="telefono">
        <input type="text" name="insTelefono" id="insTelefono" onChange="conMayusculas(this)" style="width:280px">
        <span class="textfieldRequiredMsg">Se necesita un valor.</span><span class="textfieldMinCharsMsg">No se cumple el mínimo de caracteres requerido.</span><span class="textfieldMaxCharsMsg">Se ha superado el número máximo de caracteres.</span></span></td>
	</tr>
    <tr>
		<td>Extensión*</td>
		<td><span id="extension">
        <input type="text" name="insExtension" id="insExtension" onChange="conMayusculas(this)" style="width:280px">
<span class="textfieldMaxCharsMsg">Se ha superado el número máximo de caracteres.</span></span></td>
	</tr>
    <tr>
    
    <td>Celular</td>
		<td><span id="celular">
        <input type="text" name="insCelular" id="insCelular" onChange="conMayusculas(this)" style="width:280px">
        <span class="textfieldMaxCharsMsg">Se ha superado el número máximo de caracteres.</span><span class="textfieldMinCharsMsg">No se cumple el mínimo de caracteres requerido.</span></span></td>
	</tr>    
    <tr>
		<td>Nombre del Área*</td>
		<td><span id="area">
		  <input type="text" name="insArea" id="insArea" onChange="conMayusculas(this)" style="width:280px">
		  <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
	</tr>
    <tr>
		<td>Nombre del cargo*</td>
		<td><span id="cargo">
		  <input type="text" name="insCargo" id="insCargo" onChange="conMayusculas(this)" style="width:280px">
		  <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
	</tr>
    
    <td colspan="2"><strong>DATOS DE LA CUENTA</strong></td>
    
    <tr>
		<td>Nombre de Usuario*</td>
		<td><span id="usuario">
		  <input type="text" name="insUsuario" id="insUsuario" onChange="conMayusculas(this)" style="width:280px">
		  </span><span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
	</tr>
    <tr>
		<td>Contraseña*</td>
		<td><span id="Contrasena">
		  <input type="text" name="insContrasena" id="insContrasena"  style="width:280px">
		  </span><span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
	</tr>
    
	<tr>
	  <td colspan="2" style="text-align:right"><input type="submit" class="button" value="Guardar" onClick="return confirmar('¿Esta seguro que desea registrar los datos ingresados?')"></td>
	  </tr>
</table>
<input type="hidden" name="MM_insert" value="form_add_rov">
</form>

</div>
  
   
</center>

  <script type="text/javascript">
var sprytextfield6 = new Spry.Widget.ValidationTextField("nombre", "none", {validateOn:["blur", "change"]});
var sprytextfield7 = new Spry.Widget.ValidationTextField("aPaterno", "none", {validateOn:["blur", "change"]});
var sprytextfield8 = new Spry.Widget.ValidationTextField("aMaterno", "none", {validateOn:["blur", "change"]});
var sprytextfield9 = new Spry.Widget.ValidationTextField("correo", "email", {validateOn:["blur", "change"]});
var sprytextfield10 = new Spry.Widget.ValidationTextField("telefono", "none", {minChars:10, maxChars:10, validateOn:["blur", "change"]});
var sprytextfield11 = new Spry.Widget.ValidationTextField("extension", "none", {maxChars:6, validateOn:["blur", "change"], isRequired:false});
var sprytextfield12 = new Spry.Widget.ValidationTextField("celular", "none", {minChars:10, maxChars:10, validateOn:["blur", "change"], isRequired:false});
var sprytextfield13 = new Spry.Widget.ValidationTextField("area", "none", {validateOn:["blur", "change"]});
var sprytextfield14 = new Spry.Widget.ValidationTextField("cargo", "none", {validateOn:["blur", "change"]});
var spryselect1 = new Spry.Widget.ValidationSelect("selectPrograma", {validateOn:["blur", "change"]});
var spryselect2 = new Spry.Widget.ValidationSelect("SelecTitulo", {validateOn:["blur", "change"]});
var spryconfirm1 = new Spry.Widget.ValidationConfirm("validacionCorreo", "insCorreo", {validateOn:["blur", "change"]});
var sprytextfield15 = new Spry.Widget.ValidationTextField("usuario", "none", {validateOn:["blur", "change"]});
var sprytextfield16 = new Spry.Widget.ValidationTextField("Contrasena", "none", {validateOn:["blur", "change"]});

  </script>
</body>
</html>

